package de.sendorian.app.forumArchive.script;


import java.util.Collections;
import java.util.List;

import org.junit.Test;

import de.sendorian.app.forumArchive.domain.Topic;
import de.sendorian.app.forumArchive.repository.TopicRepository;
import de.sendorian.db.DAO;

public class RepairScripts {

	@Test
	public void addTopicType() {
		TopicRepository repo = new TopicRepository();
		int firstResult = 0;
		List<Topic> all = Collections.emptyList();
		do {
			all = repo.findAllBatched(firstResult);
			for (Topic topic : all) {
				if (topic.getType() == null) {
					topic.setType(Topic.Type.TOPIC);
					repo.update(topic);
				}
			}
			firstResult += all.size();
		} while (!all.isEmpty());

		repo.shutdownDatabase();
	}

}
